//
//  SecondConfirmOrderCell.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/30.
//  Copyright © 2021 冯传昌. All rights reserved.
//


#import "SecondConfirmOrderCell.h"

@interface SecondConfirmOrderCell()

@property (nonatomic,strong) UIImageView *goodsImgV;//商品图片

@property (nonatomic,strong) UILabel *goodsInfoLB;//商品介绍lb

@property (nonatomic,strong) UILabel *goodsSkuLB;//商品型号lb

@property (nonatomic,strong) UILabel *goodsPriceLB;//商品价格lb

@property (nonatomic,strong) UILabel *goodsNumberLB;//商品数量lb

@end

@implementation SecondConfirmOrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}
#pragma mark - setter
- (void)setModel:(OrdersModel *)model{
    _model = model;
    
    [self.goodsImgV sd_setImageWithURL:[NSURL URLWithString:_model.picture]];
    self.goodsInfoLB.text = _model.name;
    self.goodsSkuLB.text = _model.norms;
    self.goodsSkuLB.width = [Configuration getLabelWidthWithText:self.goodsSkuLB.text withFont:self.goodsSkuLB.font];
    self.goodsPriceLB.text = [Configuration getTotalPriceWithPrice:_model.price withTbPrice:_model.tbprice];
    self.goodsNumberLB.text = [NSString stringWithFormat:@"X%ld",(long)_model.number];
}

#pragma mark - UI
-(void)initUI{
    [self.contentView addSubview:self.goodsImgV];
    [self.contentView addSubview:self.goodsInfoLB];
    [self.contentView addSubview:self.goodsSkuLB];
    [self.contentView addSubview:self.goodsPriceLB];
    [self.contentView addSubview:self.goodsNumberLB];
}
#pragma mark - lazy
//商品图片
-(UIImageView *)goodsImgV{
    if (!_goodsImgV) {
        _goodsImgV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 80, 80)];
        _goodsImgV.backgroundColor = MainBackColor;
        _goodsImgV.clipsToBounds = YES;
        _goodsImgV.layer.cornerRadius = 4;
    }
    return _goodsImgV;
}
//商品信息简介lb
-(UILabel *)goodsInfoLB{
    if (!_goodsInfoLB) {
        _goodsInfoLB = [[UILabel alloc] initWithFrame:CGRectMake(self.goodsImgV.right+10, self.goodsImgV.top, ScreenWidth - 140, 20)];
        _goodsInfoLB.numberOfLines = 1;
        _goodsInfoLB.textAlignment = NSTextAlignmentLeft;
        _goodsInfoLB.textColor = MainBlackTextColor;
        _goodsInfoLB.font = FontSet(14);
    }
    return _goodsInfoLB;
}
//商品信息简介lb
-(UILabel *)goodsSkuLB{
    if (!_goodsSkuLB) {
        _goodsSkuLB = [[UILabel alloc] initWithFrame:CGRectMake(self.goodsImgV.right+10, self.goodsInfoLB.bottom+8, 50, 17)];
        _goodsSkuLB.textAlignment = NSTextAlignmentLeft;
        _goodsSkuLB.backgroundColor = MainBackColor;
        _goodsSkuLB.textColor = MainGrayTextColor;
        _goodsSkuLB.font = FontSet(12);
        _goodsSkuLB.clipsToBounds = YES;
        _goodsSkuLB.layer.cornerRadius = 2;
    }
    return _goodsSkuLB;
}
//商品价格lb
-(UILabel *)goodsPriceLB{
    if (!_goodsPriceLB) {
        _goodsPriceLB = [[UILabel alloc] initWithFrame:CGRectMake(self.goodsImgV.right+10, self.goodsImgV.bottom - 18, 150, 18)];
        _goodsPriceLB.textAlignment = NSTextAlignmentLeft;
        _goodsPriceLB.textColor = RGB(255, 34, 21);
        _goodsPriceLB.font = FontSetWithWeight(15, 0.2f);
    }
    return _goodsPriceLB;
}
//商品数量简介lb
-(UILabel *)goodsNumberLB{
    if (!_goodsNumberLB) {
        _goodsNumberLB = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-75, self.goodsImgV.bottom-20, 60, 20)];
        _goodsNumberLB.textAlignment = NSTextAlignmentRight;
        _goodsNumberLB.textColor = MainGrayTextColor;
        _goodsNumberLB.font = FontSet(14);
    }
    return _goodsNumberLB;
}




@end
